import swal from 'sweetalert'
export default {
  install: function (Vue) {
    Vue.prototype.confirm = function (msg, fun) {
        swal({
          title: '提示',
          text: msg,
          icon: 'warning',
          buttons: ['取消', '确认'],
        }).then(willDelete => {
          if (willDelete) {
            fun()
          }
        })
      },
      Vue.prototype.alertok = function () {
        let msg = arguments[0] || '操作成功'
        let fun = arguments[1]
        swal('提示', msg, 'success').then(fun)
      },
    Vue.prototype.alertfail = function () {
      let msg = arguments[0] || '操作失败'
      let fun = arguments[1]
      swal('错误', msg, 'error').then(fun)
    }
  }
}
